package com.jy.rhin.infra.repo.document.content.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.jy.rhin.infra.repo.document.content.po.DocumentContentPO;
import com.jy.rhin.sdk.dto.document.query.GetContentRespDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author dhl
 * @date 2022/6/1
 * @Description
 */
@Mapper
@Repository
public interface DocumentContentMapper extends BaseMapper<DocumentContentPO> {

    /**
     * 获取文档内容列表
     * @param wrapper
     * @return
     */
    @Select(" SELECT a.content, a.unique_id AS documentUniqueId, \n" +
            " a.repository_unique_id AS repositoryUniqueId,\n" +
            " b.title AS title, b.huan_zhe_xm AS huanZheXm \n" +
            " FROM t_document_content a LEFT JOIN t_document_entry b ON a.unique_id = b.unique_id \n" +
            " AND a.repository_unique_id = b.repository_unique_id \n"+
            " ${ew.customSqlSegment} ")
    List<GetContentRespDto> queryDocumentContentList(@Param(Constants.WRAPPER) QueryWrapper<Object> wrapper);
}
